package com.lifp.controller;

import com.lifp.dto.BaiDuFaceImageRegisterDTO;
import com.lifp.service.BaiDuAiRestFaceLibraryService;
import com.lifp.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description REST 人脸库接口controller
 * @Author lifp
 * @Date 2023/2/26
 * @Version 1.0
 */
@Api(tags = "REST 人脸库接口",description = "REST 人脸库接口")
@RestController
@RequestMapping("baidu/rest/library/face")
public class BaiDuAiRestFaceLibraryController {
    @Autowired
    private BaiDuAiRestFaceLibraryService restFaceLibraryService;

    /**
     *@Description 人脸注册
     *@Author lifp
     *@Date 2023/2/26
     *@param imageRegisterDTO
     *@Return 
     */
    @ApiOperation("人脸注册")
    @PostMapping("register")
    public Result registerFace(@RequestBody BaiDuFaceImageRegisterDTO imageRegisterDTO){
        return restFaceLibraryService.registerFace(imageRegisterDTO);
    }

    /**
     *@Description 人脸更新
     *@Author lifp
     *@Date 2023/2/26
     *@param imageRegisterDTO
     *@Return
     */
    @ApiOperation("人脸更新")
    @PostMapping("update")
    public Result updateUser(@RequestBody BaiDuFaceImageRegisterDTO imageRegisterDTO){
        return restFaceLibraryService.updateUser(imageRegisterDTO);
    }

    /**
     *@Description base64 人脸识别登录
     *@Author lifp
     *@Date 2023/2/26
     *@param image64
     *@Return
     */
    @ApiOperation("base64 人脸识别登录")
    @PostMapping("login/base64")
    public Result loginByFaceImg64(@RequestParam("image64") String image64){
        return restFaceLibraryService.loginByFaceImg64(image64);
    }

    /**
     *@Description image 人脸识别登录
     *@Author lifp
     *@Date 2023/2/26
     *@param imgFile
     *@Return
     */
    @ApiOperation("image 人脸识别登录")
    @PostMapping("login/image")
    public Result loginByFaceImgFile(@RequestPart("file") MultipartFile imgFile){
        return restFaceLibraryService.loginByFaceImgFile(imgFile);
    }
}
